
import { request } from '@/utils/request';


import { BaseModel } from '@/api/common/baseModel'

/**
 * 商品属性
 */
export interface Model extends BaseModel {
  /** 备注 */
  remark?: string
}

/**
 * 属性值
 */
export interface PropertyValueVO extends BaseModel {
  /** 属性项的编号 */
  propertyId?: number
  /** 备注 */
  remark?: string
}

/**
 * 商品属性值的明细
 */
export interface PropertyValueDetailVO extends BaseModel {
  /** 属性项的编号 */
  propertyId: string // 属性的编号
  /** 属性的名称 */
  propertyName: string
  /** 属性值的编号 */
  valueId: string
  /** 属性值的名称 */
  valueName: string
}

// ------------------------ 属性项 -------------------

// 更新属性项
export const update = (data: any, ) => {
  return request.put({
    url: '/staff/web/userCenter/trade/goods/goodsProps/update.json',
    data
  })
}

// 删除属性项
export const del = (id: string) => {
  return request.delete({ url: `/staff/web/userCenter/trade/goods/goodsProps/del.json?id=${id}` })
}

// 获得属性项
export const getById = (id: string): Promise<Model> => {
  return request.get({ url: `/staff/web/userCenter/trade/goods/goodsProps/getById.json?id=${id}` })
}

// 获得属性项分页
export const getPage = (params: any) => {
  return request.get({
    url: '/staff/web/userCenter/trade/goods/goodsProps/page.json',
    params
  })
}

// 获得属性项列表
export const getPropertyList = (params: any) => {
  return request.get({
    url: '/staff/web/userCenter/trade/goods/goodsProps/page.json',
    params
  })
}

// 获得属性项列表
export const getPropertyListAndValue = (params: any) => {
  return request.get({
    url: '/staff/web/userCenter/trade/goods/goodsProps/get-value-list',
    params
  })
}

// ------------------------ 属性值 -------------------

// 获得属性值分页
export const getPropertyValuePage = (params:  any  & any) => {
  return request.get({
    url: '/staff/web/userCenter/trade/goods/goodsProps/value/page.json',
    params
  })
}

// 更新属性值
export const updateValue = (data: PropertyValueVO) => {
  return request.put({
    url: '/staff/web/userCenter/trade/goods/goodsProps/value/update.json',
    data
  })
}

// 删除属性值
export const delValue = (id: string) => {
  return request.delete({ url: `/staff/web/userCenter/trade/goods/goodsProps/value/del.json?id=${id}` })
}
